﻿@model LS.Models.CardManageModel




@*@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

}*@



<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Create</h3>
</div>
<div class="modal-body">
    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>MemberCard</legend>

            <div class="editor-label">
                @Html.LabelFor(model => model.Card.SeiralNumber)
            </div>
            <div class="editor-field">
                @*@model.Card.SeiralNumber= ViewBag.NewSeiralNumber;*@
                @Html.EditorFor(model => model.Card.SeiralNumber)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.ExpireDate)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ExpireDate)
                @Html.ValidationMessageFor(model => model.ExpireDate)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Description)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Description)
                @Html.ValidationMessageFor(model => model.Description)
            </div>

            <div class="modal-footer">
                <input type="button" value="Create" class="btn btn-primary" onclick="DoAjaxPostAndMore(this)" data-dismiss="modal" aria-hidden="true" />
                @*                @Html.ActionLink("Cancel", "Index", null, new { @class = "btn btn-inverse" })*@
                <button class="btn btn-inverse" data-dismiss="modal" aria-hidden="true">Close</button>
            </div>
        </fieldset>
    }
</div>



<div>
</div>
<link rel="stylesheet" href="~/Content/themes/base/jquery.ui.all.css" />
<script src="@Url.Content("~/Scripts/ui/jquery.ui.core.js")"></script>
<script src="@Url.Content("~/Scripts/ui/jquery.ui.widget.js")"></script>
<script src="@Url.Content("~/Scripts/ui/jquery.ui.datepicker.js")"></script>
<script type="text/javascript">
    $(function () {
        $("#ExpireDate").datepicker();
        $("#ExpireDate").datepicker("option", "dateFormat", "yy-mm-dd");
        var today = new Date();
        var defaultExpireDate = today.setFullYear(today.getFullYear() + 1);
        $('#ExpireDate').datepicker('setDate', today);
    });

    function DoAjaxPostAndMore(btnClicked) {
        var $form = $(btnClicked).parents('form');

        $.ajax({
            type: "POST",
            url: $form.attr('action'),
            data: $form.serialize(),
            error: function (xhr, status, error) {
                //do something about the error
            },
            success: function (response) {
                //do something with response
                //alert(response.s);
                //alert(response.Id);
                LoadMyCards(response);
            }
        });

        return false;// if it's a link to prevent post

    }
</script>
